﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="QuanLyBinhLuan.ascx.cs" Inherits="Main.Administrator.QuanLyBinhLuan" %>
 <script type="text/javascript">
    function Check(id1, id2, id3)
    {
        var txtTen = document.getElementById(id1);
        var txtEmail = document.getElementById(id2);
        var txtNoiDung = document.getElementById(id3);
        var kq='';
        if(txtTen.value == '')
            kq+='-Vui lòng nhập tên.';
        if( txtEmail.value == 0)
            kq+='\n-Vui lòng nhập địa chỉ Email.';
        if(txtNoiDung.value == '')
            kq+='\n-Vui lòng nhập nội dung bình luận.';
        if(kq!='')
        {
            alert(kq);
            return false;
        }
        // Check Email
        if(!validEmail(txtEmail.value))
        {
            alert("Email không hợp lệ.");
            return false;
        }
        return true;
    }
    function validEmail(email)
    {      
	    var emailReg = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
	    return emailReg.test(email); 
    }
 </script>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div id="Location" class="Location" runat="server"><a href="../Administrator.aspx">Administrator Page</a> >> Quản lý Bình Luận</div>
<div id="Notice" class="Notice" runat="server" visible="false"></div>
<div id="Errors" class="Errors" runat="server" visible="false"></div>
<div id="Form">
     <asp:GridView SkinID="GridViewSkin" DataKeyNames="MaBinhLuan,TinhTrang" ID="GridView1" runat="server" 
        AutoGenerateColumns="False" AllowPaging="True" AllowSorting="true"  
        OnPageIndexChanging="GridView1_PageIndexChanging" OnRowDeleting="GridView1_RowDeleting" 
        OnRowCommand="GridView1_RowCommand" OnRowDataBound="GridView1_RowDataBound" OnSorting="GridView1_Sorting">
        <Columns>
           <asp:TemplateField ItemStyle-Width="4%">
                <HeaderTemplate>
                    <asp:CheckBox ID="chkAll" runat="server" />
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:CheckBox ID="chkBinhLuan" runat="server" />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="ID" ItemStyle-Width="7%" SortExpression="MaBinhLuan">
                <ItemTemplate>
                    <asp:Label id="lblMaBinhLuan" runat="server" Text='<%# Eval ( "MaBinhLuan" ) %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Nội Dung" ItemStyle-Width="30%" SortExpression="NoiDung">
                <ItemTemplate>
                    <asp:Label id="lblNoiDung" Text='<%# NoiDung((string)Eval("NoiDung"),(DateTime)Eval("NgayKhoiTao")) %>' runat="server" ></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Tác Giả" ItemStyle-Width="20%" SortExpression="TacGia">
                <ItemTemplate>
                    <asp:Label id="lblTacGia" Text='<%# TacGia((string)Eval("HoTen"),(string)Eval("Email")) %>' runat="server">
                   </asp:Label>
                </ItemTemplate>
           </asp:TemplateField>
            <asp:TemplateField HeaderText="Trạng Thái" ItemStyle-Width="10%">
                <ItemTemplate>
                <center>
                      <asp:LinkButton ID="lnkTinhTrang" CommandName="CapNhat_TinhTrang" CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>' runat="server" ToolTip="Cập nhật Tình Trạng">
                          <asp:Image ID="imgTinhTrang" runat="server" ImageAlign="Middle" />
                    </asp:LinkButton>
                </center>
                </ItemTemplate>
           </asp:TemplateField>
            <asp:TemplateField HeaderText="Thuộc Bài Viết" ItemStyle-Width="20%">
                <ItemTemplate>
                    <asp:Label id="lblBaiViet" Text='<%# BaiViet((object)Eval("BaiViet")) %>'  runat="server"></asp:Label>
                </ItemTemplate>
           </asp:TemplateField>
            <asp:TemplateField HeaderText="Thao Tác">
                <ItemTemplate>
                    <asp:LinkButton ID="lnkEdit" CommandName="CapNhat" CommandArgument='<%# Eval ( "MaBinhLuan" ) %>' runat="server" ToolTip="Sửa">
                        <asp:Image ID="imgEdit" runat="server" SkinID="Edit" />
                    </asp:LinkButton>
                    <asp:LinkButton ID="lnkDelete" CommandName="Delete" runat="server" ToolTip="Xóa" OnClientClick="return confirm('Bạn có muốn xóa thật không?');">
                    <asp:Image ID="imgDelete" runat="server" SkinID="Delete" />
                    </asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
     &nbsp;
    <br />
    <label><b>Bulk Action</b>: </label>
    <asp:LinkButton runat="server" CssClass="Button2" id="lnkDeleteAll" OnClientClick="return confirm('Bạn có muốn xóa thật không?');" Text="Xóa" OnClick="lnkDeleteAll_Click"></asp:LinkButton>
    <br />
    <br />
  <div class="ui-widget-content ui-corner-all" id="pSuaBinhLuan" style="display: none;">
        <h3 class="ui-widget-header ui-corner-all">&nbsp;Sửa Bình Luận</h3>
        <p>
        <table>
            <tr>
                <td>Họ Tên:</td>
                <td>
                    <asp:HiddenField ID="hiddenMaBinhLuan" runat="server" />
                    <asp:TextBox ID="txtHoTen" runat="server"></asp:TextBox></td>
                  <td>Email:</td>
                <td><asp:TextBox ID="txtEmail" runat="server"></asp:TextBox></td>
            </tr>
               <tr>
                <td>Nội Dung:</td>
                <td colspan="3"><asp:TextBox Width="400px" ID="txtNoiDung" runat="server" TextMode="MultiLine" Rows="5"></asp:TextBox></td>
            </tr>
            <tr>
                <td colspan="4" align="right">
                <br />
                <asp:LinkButton ID="lnkSave" CssClass="Button2" Text="Lưu" runat="server" OnClick="lnkSave_Click"></asp:LinkButton></td>
                <br />
                <br />
                <br />
            </tr>
            
        </table>
        </p>
    </div>
</div> <!-- Form -->
</ContentTemplate>
</asp:UpdatePanel>

     <asp:Image ID="imgSave" runat="server" SkinID="Save" Visible="false" />
     <asp:Image ID="imgCancel" runat="server" SkinID="Cancel" Visible="false" />
     <asp:Image ID="imgAsc" runat="server" SkinID="ASC" Visible="false" />
     <asp:Image ID="imgDesc" runat="server" SkinID="DESC" Visible="false" />
     
     
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
       <ProgressTemplate>
                <div class="overlay" id="divProgress" style="position: absolute">
                    <center>
                        <asp:Image runat="server" ID="AjaxLoading" SkinID="AjaxLoadingIndicator" />
                    </center>
                </div>
        </ProgressTemplate>
</asp:UpdateProgress>